﻿using BLL.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Autofac.Shell
{
    class Program
    {
        private static IContainer Container { get; set; }
        static void Main(string[] args)
        {
            // Create your builder.
            var builder = new ContainerBuilder();

            // Usually you're only interested in exposing the type
            // via its interface:
            builder.RegisterType<AutofacService>().As<ICoreService>();

            // However, if you want BOTH services (not as common)
            // you can say so:
            builder.RegisterType<AutofacService>().AsSelf().As<ICoreService>();

            Container = builder.Build();

            using (var scope = Container.BeginLifetimeScope())
            {
                var writer = scope.Resolve<ICoreService>();
                writer.GetGUID();
            }
        }
    }

    public class AutofacService : ICoreService
    {
        private Guid guid = Guid.NewGuid();
        public Guid GetGUID()
        {
            return guid;
        }

        public object GetService(Type serviceType)
        {
            throw new NotImplementedException();
        }
    }



}
